package com.randi.generator.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.randi.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotBlank;

/**
 * @author ziye
 */
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("gen_table_column")
@ApiModel(value = "GenTableColumn对象", description = "GenTableColumn对象")
public class GenTableColumn extends BaseEntity {

    @TableField(exist = false)
    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "key")
    private Long key;

    @TableId(value = "column_id", type = IdType.ASSIGN_ID)
    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "字段ID")
    private Long columnId;

    @TableField(value = "`table_id`")
    @ApiModelProperty(value = "表ID")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long tableId;

    @TableField(value = "`column_name`")
    @ApiModelProperty(value = "字段名称")
    @NotBlank(message = "字段名不能为空")
    private String columnName;

    @TableField(value = "`column_type`")
    @ApiModelProperty(value = "字段类型")
    @NotBlank(message = "字段类型不能为空")
    private String columnType;

    @TableField(value = "`column_comment`")
    @ApiModelProperty(value = "字段描述")
    private String columnComment;

    @TableField(value = "`java_type`")
    @ApiModelProperty(value = "java类型")
    private String javaType;

    @TableField(value = "`java_field`")
    @ApiModelProperty(value = "java字段名")
    @NotBlank(message = "Java字段名不能为空")
    private String javaField;

    @TableField(value = "`is_primary_key`")
    @ApiModelProperty(value = "是否主键")
    private Integer isPrimaryKey;

    @TableField(value = "`is_increment`")
    @ApiModelProperty(value = "是否自增")
    private Integer isIncrement;

    @TableField(value = "`is_required`")
    @ApiModelProperty(value = "是否必填")
    private Integer isRequired;

    @TableField(value = "`is_insert`")
    @ApiModelProperty(value = "是否插入字段")
    private Integer isInsert;

    @TableField(value = "`is_edit`")
    @ApiModelProperty(value = "是否编辑字段")
    private Integer isEdit;

    @TableField(value = "`is_list`")
    @ApiModelProperty(value = "是否列表字段")
    private Integer isList;

    @TableField(value = "`is_query`")
    @ApiModelProperty(value = "是否查询字段")
    private Integer isQuery;

    @TableField(value = "`query_type`")
    @ApiModelProperty(value = "查询方式", notes = "EQ等于、NE不等于、GT大于、LT小于、LIKE模糊、BETWEEN范围")
    private String queryType;

    @TableField(value = "`html_type`")
    @ApiModelProperty(value = "显示类型", notes = "input文本框、textarea文本域、select下拉框、checkbox复选框、radio单选框、datetime日期控件、image图片上传控件、upload文件上传控件、editor富文本控件")
    private String htmlType;

    @TableField(value = "`dict_type`")
    @ApiModelProperty(value = "字典类型")
    private String dictType;

    @TableField(value = "`sort`")
    @ApiModelProperty(value = "排序")
    private Integer sort;

    public void setKey(Long key) {
        this.key = null;
    }

    public Long getKey() {
        return this.columnId;
    }
}
